<html>
	<head>
		<title>Microchip TCP/IP Stack Home</title>

		<script language="JavaScript">
			var	xmlHttp;
			var ObjArray = new Array;

			function GetXmlHttpObject(handler)
			{
				var objXmlHttp = null;

				if(navigator.userAgent.indexOf("MSIE")>=0)
				{
					var ClassName = "Msxml2.XMLHTTP";
					if(navigator.appVersion.indexOf("MSIE 5.5")>=0)
					{
					ClassName = "Microsoft.XMLHTTP";
					}
			
					try
					{
						objXmlHttp = new ActiveXObject(ClassName);
						objXmlHttp.onreadystatechange = handler;
						return objXmlHttp;           
					}
					catch(e)
					{
						alert("Error: ActiveX scripting may be disabled.");
						return;
					}
				}
				else
				{
					try
					{
						objXmlHttp = new XMLHttpRequest();
						objXmlHttp.onload = handler;
						objXmlHttp.onerror = handler;
						return objXmlHttp;
					}
					catch(e)
					{
						alert("Error: Browser may not be supported or browser security restrictions are too high.  XMLHttpRequest() support is required.");
					}
				}
			}

			function StateChanged()
			{
				if(xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
				{
					document.getElementById("txtAutoUpdateStatus").innerHTML=xmlHttp.responseText;
					xmlHttp = null;
					UpdateStatus();
				}
			}


			function UpdateStatus()
			{
				xmlHttp = GetXmlHttpObject(StateChanged);
				xmlHttp.open("GET", "Status.cgi" , true);
				xmlHttp.send(null);
			}

			function GetServerFile(FileName, AssignTo)
			{
				var NiftyObj = new Object();
				NiftyObj.XMLDevice = new GetXmlHttpObject(StateChanged2);
				NiftyObj.XMLDevice.open("GET", FileName, true);
				NiftyObj.XMLDevice.send(null);
				NiftyObj.Text = AssignTo;
				ObjArray.push(NiftyObj);
			}

			function StateChanged2()
			{
				for(i in ObjArray)
				{
					if(ObjArray[i].XMLDevice.readyState == 4 || ObjArray[i].XMLDevice.readyState == "complete")
					{
						if(ObjArray[i].Text != "")
						{
							document.getElementById(ObjArray[i].Text).innerHTML=ObjArray[i].XMLDevice.responseText;
						}
						
						if(ObjArray[i].Text == "txtAutoUpdateStatus")
						{
							GetServerFile("Status.cgi", "txtAutoUpdateStatus");
						}
						
						delete ObjArray[i].XMLDevice;
						delete ObjArray[i];
					}
				}
			}



		</script>


	</head>
	<body bgcolor="white" onload="UpdateStatus(); GetServerFile('Version.cgi','txtStackVersion'); GetServerFile('BuildDate.cgi','txtBuildDate');">

		<table border="0" width="100%" height="87">
			<tr>
				<td height="83">
						<font size="6" face="MS Sans Serif">
							&nbsp;</font></b><font size="4" face="Arial Black">www.olimex.com/dev</font></td>
			</tr>
			<tr>
				<td bgcolor="#000000">
					&nbsp;</td>
			</tr>
		</table>

		<br>

			<table border="0" cellpadding="0" cellspacing="0" width="100%">
				<tr>
					<td valign="top" width="100%">
						<b>Welcome!</b>
						<br>
							Stack version: <span id="txtStackVersion">Unknown</span><br>
								Build date: <span id="txtBuildDate">Unknown</span><br>

									<p>
									PIC-WEB development board is used to demonstrate the power and abilities of an 8-bit embedded web server.
									This board is produced by Olimex Ltd.  
									</p>
									<p>
										The bottom portion of this page illustrates real-time control of the demo board. The &quot;Status&quot;
										section refreshes with board information periodically using JavaScript and the &quot;Actions&quot; 
										section issues commands to toggle the on-board RELAYs or write text to LCD. You can push the on-board 
										buttons or rotate the potentiometer and see the new data. You may also get current temperature.
									</p>
									<p>
									If your browser does not support AJAX, you may wish to see <a href="Index.cgi">this page</a> for an easily refreshable 
									static snapshot of the board state with control options.
									</p>
					</td>
				</tr>
			</table>

			<table cellpadding="3">
				<form>
					<tr>
						<td>
							<b>Actions</b>
						</td>
					</tr>
					<tr>
						<td>Toggle outputs:</td>
						<td>
							<input type="button" value="LD1" onclick="GetServerFile('0?0=LED1','')"></input>
					</td>
				</tr>
			</form>
			<tr>
				<td>&nbsp;</td>
			</tr>
			<tr>
				<td>
					<b>Status</b>
				</td>
			</tr>
		</table>

		<span id="txtAutoUpdateStatus">Loading...</span>


	</body>
</html>